package cn.wolfcode._IOday01_.work04;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;

public class Text00 {
    public static void main(String[] args) throws IOException {
        String str = "gjsagd,uidojisd[]/'gr][;]gw];g.sg;];[we;[;;g][e;w][;fdlf]sdl]g[rkg[joafopg9ako;aegffs******//dfoijOIHJIYUGYTC*" +
                "///(()__RT0,has9i.hUIGUY/GYGBYBBBBUHUIgyuhasdUHYU";
        String str2 = "" ;
        String str3 = "" ;
        for (int i = 0; i < str.length(); i++) {
            if (str.charAt(i) >= 'A' && str.charAt(i) <= 'Z'){
                str2 += str.charAt(i);
            }else if (str.charAt(i) >= 'a' && str.charAt(i) <= 'z'){
                str3 += str.charAt(i);
            }
        }
        String str4 = str2+str3 ; //字符串拼接
        TreeMap<Character,Integer> map = new TreeMap<>();
        for (int i = 0; i < str4.length(); i++) {
            char c = str4.charAt(i);
            if (map.containsKey(c)){
                int i1 = map.get(c);
                i1++;
                map.put(c,i1);
            }else{
                map.put(c,1);
            }
        }
        String s1 = "" ;
        Set<Map.Entry<Character,Integer>> set = map.entrySet();
        for (Map.Entry<Character,Integer> m : set){
            Character key = m.getKey();
            Integer value = m.getValue();
            s1 += key+"("+value+"),";
        }
        String sum = s1.substring(0, s1.length() - 1);
        System.out.println(sum);

        FileWriter fileWriter = new FileWriter(new File("C:\\Users\\China\\Desktop\\9572.txt"));
        fileWriter.write(sum);
        fileWriter.flush();
        fileWriter.close();
    }
}
